package com.luo.chengrui.module.crbpm.dal.mysql.orgprocess;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import com.luo.chengrui.module.crbpm.dal.dataobject.orgprocess.BpmOrgProcessDO;
import org.apache.ibatis.annotations.Mapper;
import com.luo.chengrui.module.crbpm.controller.admin.orgprocess.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 组织模板明细 Mapper
 *
 * @author luodz
 */
@Mapper
public interface BpmOrgProcessMapper extends BaseMapperX<BpmOrgProcessDO> {

    default PageResult<BpmOrgProcessDO> selectPage(BpmOrgProcessPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BpmOrgProcessDO>()
                .eqIfPresent(BpmOrgProcessDO::getOrgDefinitionId, reqVO.getOrgDefinitionId())
                .eqIfPresent(BpmOrgProcessDO::getModelId, reqVO.getModelId())
                .eqIfPresent(BpmOrgProcessDO::getProcessDefinitionId, reqVO.getProcessDefinitionId())
                .eqIfPresent(BpmOrgProcessDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BpmOrgProcessDO::getVersion, reqVO.getVersion())
                .betweenIfPresent(BpmOrgProcessDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BpmOrgProcessDO::getId));
    }

    default List<BpmOrgProcessDO> selectList(BpmOrgProcessExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BpmOrgProcessDO>()
                .eqIfPresent(BpmOrgProcessDO::getOrgDefinitionId, reqVO.getOrgDefinitionId())
                .eqIfPresent(BpmOrgProcessDO::getModelId, reqVO.getModelId())
                .eqIfPresent(BpmOrgProcessDO::getProcessDefinitionId, reqVO.getProcessDefinitionId())
                .eqIfPresent(BpmOrgProcessDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BpmOrgProcessDO::getVersion, reqVO.getVersion())
                .betweenIfPresent(BpmOrgProcessDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BpmOrgProcessDO::getId));
    }

    List<BpmOrgProcessDO> selectListByModelIds(@Param("orgDefinitionId") String orgDefinitionId, @Param("modelIds") List<String> createReqModelIds);
}
